package base

import (
	"context"
	"rewords-server-2024/internal/library/cache"

	"rewords-server-2024/api/base/cacheAPI"
)

func (c *ControllerCacheAPI) ClearData(ctx context.Context, req *cacheAPI.ClearDataReq) (res *cacheAPI.ClearDataRes, err error) {
	//return nil, gerror.NewCode(gcode.CodeNotImplemented)
	if req.Key != "" {
		_, err = cache.Instance().Remove(ctx, req.Key)
	} else {
		err = cache.Instance().Clear(ctx)
	}
	return
}
